import { Component } from 'react'

class Obj extends Component {
  state = {
    userinfo: {
      name: '李四',
    },
  }
  changeName = () => {
    let userinfo = this.state.userinfo
    userinfo.name = '张三'
    this.setState({
      userinfo,
    })
  }
  render() {
    return (
      <>
        <button> 姓名：{this.state.userinfo.name} </button>
        <button onClick={this.changeName}> 修改姓名 </button>
      </>
    )
  }
}

export default Obj
